package com.iofiledDemo;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class A3 {


    public static void main(String[] args) {

        A3 a3 = new A3();
        String filePath1 = "E:\\BaiduNetdiskDownload\\搞笑图\\00cc40eee8e44720add7b2bb0485c0d3_th.jpg";
        String filePath2 = "D:\\f.jpg";

        a3.copyFile(filePath1,filePath2);

    }


    public void copyFile(String filePath_old, String filePath_new){

        FileInputStream fis = null;
        FileOutputStream fout = null;

        try {
            fis = new FileInputStream(filePath_old);
            fout = new FileOutputStream(filePath_new);

            int size = 0;
            try {
                size = fis.available();
                byte[] array = new byte[size];
                fis.read(array);
                fout.write(array);


            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }finally {

            if(fis!=null){
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if(fout!=null){

                try {
                    fout.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }


        }


    }






}
